#include <REGX52.H>
#include "LCD1602.h"
#include "timer.h"
#include "stopwatch.h"


unsigned char table1[]={0x04,0x0E,0x1F,0x04,0x04,0x04,0x04,0x04};
unsigned char table2[]={0x04,0x04,0x04,0x0E,0x1F,0x1F,0x1B,0x11};

unsigned T1count = 0;
unsigned int ms_100 = 0;
unsigned int s = 0;
unsigned int min = 0;

void clear(){
	ms_100 = 0;
	s = 0;
	min = 0;
}

void plus(){
	LCD_Init();
	Timer0_Init();
	Timer1_Init();
	Stopwatch_ShowTime();
}

void CF(){
	if(ms_100 == 10){
		ms_100 = 0;
		s++;
	}
	if(s == 60){
		s = 0;
		min++;
	}
	min %= 60;
}

void main(){
//		basic();
	plus();
	while(1);
}

void Timer0_Routine() interrupt 1{
	TL0 = 0xCD;	
	TH0 = 0xF8;	
	KeyCheck();
}

void Timer1_Routine() interrupt 3{
	TL1 = 0x00;
	TH1 = 0x4C;
	T1count++;
	T1count %= 2;
	if(!T1count){
		ms_100++;
		CF();
		Stopwatch_ShowTime();
	}
	
}
